package cn.vcjf.weapp.api.active.entity;

import cn.vcjf.weapp.common.util.DateUtils;
import cn.vcjf.weapp.common.util.IdGen;
import cn.vcjf.weapp.common.web.JsonDateTypeConvert;
import cn.vcjf.weapp.common.web.PageModel;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * <p>
    * 活动记录详情
    * </p>
 *
 * @author zhengzihang
 * @since 2018-09-26
 */
@TableName("vc_goods_active_record")
public class GoodsActiveRecord extends PageModel<GoodsActiveRecord> {

    /**
     *  活动状态(0,创建中,1,进行中,2完成,3未完成)
     */
    public static int COLLAGE_STATUS_CREATING = 0;
    public static int COLLAGE_STATUS_ING = 1;
    public static int COLLAGE_STATUS_OK = 1;
    public static int COLLAGE_STATUS_FAIL = 1;

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 活动编号(同一拼团,同一编号)
     */
    private String activeOrderNo;

    /**
     * 发起活动客户id
     */
    private Integer userId;

    /**
     * 活动表id
     */
    private Integer goodsActiveId;

    /**
     * vc_goods_group表主键（商品具体规格）
     */
    private Integer goodsGroupId;

    /**
     * 活动人数
     */
    private Integer collageNum;

    /**
     * 已参与人数
     */
    private Integer collageNumIn;
    /**
     * 已砍价格
     */
    private BigDecimal cutedPrice;
    /**
     * 活动状态(1,进行中,2完成,3未完成,4取消)
     */
    private Integer status;

    /**
     * 活动结束时间
     */
    private Date activeEndTime;
    /**
     * 成团时间
     */
    private Date completeTime;

    /*****************************************************/
    /**
     * 姓名
     */
    @TableField(exist=false)
    private String name;
    /**
     * 头像
     */
    @TableField(exist=false)
    private String headPhoto;
    /**
     * 活动类型(1拼团,2砍价)
     */
    @TableField(exist=false)
    private Integer activetype;

    /**
     * 原价
     */
    @TableField(exist=false)
    private BigDecimal costPrice;

    /**
     * 活动价
     */
    @TableField(exist=false)
    private BigDecimal activePrice;

    /**
     * 可砍价格
     */
    @TableField(exist=false)
    private BigDecimal bargainPrice;

    /**
     * 活动时间(砍价有效时间,单位分钟)
     */
    @TableField(exist=false)
    private Integer activeTime;
    /**
     * 活动名称
     */
    @TableField(exist=false)
    private String activeName;
    /**
     * 活动描述
     */
    @TableField(exist=false)
    private String activeDes;
    /**
     * 商品名称
     */
    @TableField(exist=false)
    private String goodsName;

    /**
     * 商品描述
     */
    @TableField(exist=false)
    private String goodsDes;
    /**
     * 商品图片
     */
    @TableField(exist=false)
    private String goodsFilesId;

    /**
     * 参与活动用户集合
     */
    @TableField(exist=false)
    private List<UserActive> activeUserList;

    public Date getCompleteTime() {
        return completeTime;
    }

    public void setCompleteTime(Date completeTime) {
        this.completeTime = completeTime;
    }

    public BigDecimal getCutedPrice() {
        return cutedPrice;
    }

    public void setCutedPrice(BigDecimal cutedPrice) {
        this.cutedPrice = cutedPrice;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getHeadPhoto() {
        return headPhoto;
    }

    public void setHeadPhoto(String headPhoto) {
        this.headPhoto = headPhoto;
    }

    public Integer getActivetype() {
        return activetype;
    }

    public void setActivetype(Integer activetype) {
        this.activetype = activetype;
    }

    public BigDecimal getCostPrice() {
        return costPrice;
    }

    public void setCostPrice(BigDecimal costPrice) {
        this.costPrice = costPrice;
    }

    public BigDecimal getActivePrice() {
        return activePrice;
    }

    public void setActivePrice(BigDecimal activePrice) {
        this.activePrice = activePrice;
    }

    public BigDecimal getBargainPrice() {
        return bargainPrice;
    }

    public void setBargainPrice(BigDecimal bargainPrice) {
        this.bargainPrice = bargainPrice;
    }

    public Integer getActiveTime() {
        return activeTime;
    }

    public void setActiveTime(Integer activeTime) {
        this.activeTime = activeTime;
    }

    public String getActiveName() {
        return activeName;
    }

    public void setActiveName(String activeName) {
        this.activeName = activeName;
    }

    public String getActiveDes() {
        return activeDes;
    }

    public void setActiveDes(String activeDes) {
        this.activeDes = activeDes;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public String getGoodsDes() {
        return goodsDes;
    }

    public void setGoodsDes(String goodsDes) {
        this.goodsDes = goodsDes;
    }

    public String getGoodsFilesId() {
        return goodsFilesId;
    }

    public void setGoodsFilesId(String goodsFilesId) {
        this.goodsFilesId = goodsFilesId;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }
    public String getActiveOrderNo() {
        return activeOrderNo;
    }

    public void setActiveOrderNo(String activeOrderNo) {
        this.activeOrderNo = activeOrderNo;
    }
    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }
    public Integer getGoodsActiveId() {
        return goodsActiveId;
    }

    public void setGoodsActiveId(Integer goodsActiveId) {
        this.goodsActiveId = goodsActiveId;
    }
    public Integer getGoodsGroupId() {
        return goodsGroupId;
    }

    public void setGoodsGroupId(Integer goodsGroupId) {
        this.goodsGroupId = goodsGroupId;
    }
    public Integer getCollageNum() {
        return collageNum;
    }

    public void setCollageNum(Integer collageNum) {
        this.collageNum = collageNum;
    }
    public Integer getCollageNumIn() {
        return collageNumIn;
    }

    public void setCollageNumIn(Integer collageNumIn) {
        this.collageNumIn = collageNumIn;
    }
    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }
    @JsonSerialize(using = JsonDateTypeConvert.class)
    public Date getActiveEndTime() {
        return activeEndTime;
    }

    public void setActiveEndTime(Date activeEndTime) {
        this.activeEndTime = activeEndTime;
    }

    @TableField(exist = false)
    public static String[] preFix = {"T-","C-"};
    @Override
    public void preInsert(){
        super.preInsert();
        this.activeOrderNo = preFix[activetype]+DateUtils.getDate("yyyyMMddHHmmss")+IdGen.getRandomString(4)+this.userId;
        this.status = GoodsActiveRecord.COLLAGE_STATUS_CREATING;
    }
    @Override
    public void preUpdate(){
        super.preInsert();
    }
    @Override
    public String toString() {
        return "GoodsActiveRecord{" +
        "id=" + id +
        ", activeOrderNo=" + activeOrderNo +
        ", userId=" + userId +
        ", goodsActiveId=" + goodsActiveId +
        ", goodsGroupId=" + goodsGroupId +
        ", collageNum=" + collageNum +
        ", collageNumIn=" + collageNumIn +
        ", status=" + status +
        ", activeEndTime=" + activeEndTime +
        ", createUser=" + createUser +
        ", createTime=" + createTime +
        ", updateUser=" + updateUser +
        ", updateTime=" + updateTime +
        ", deleteFlag=" + deleteFlag +
        ", sysUserId=" + sysUserId +
        "}";
    }

	public void setActiveUserList(List<UserActive> activeUserList) {
		this.activeUserList = activeUserList;
	}

	public List<UserActive> getActiveUserList() {
		return activeUserList;
	}
}
